﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Model;

namespace BLL
{
    public partial class wasteBookManager
    {
        public List<wasteBook> GetAll(string memberId)
        {
            return db.GetAll().Where(p => p.memberCardId == memberId).ToList<wasteBook>();
        }

        //根据条件获取流水
        public IQueryable<wasteBook> GetByTime(string start, string end, string opertor,string memberCardId)
        {
            ZG_OAEntities ds = new ZG_OAEntities();
            var query = from obj in ds.wasteBook orderby obj.id descending select obj;
            if (!string.IsNullOrEmpty(start) && start != "null")
            {
                DateTime dt = Convert.ToDateTime(start);
                query = from obj in query where obj.date >= dt orderby obj.id descending select obj;
            }
            if (!string.IsNullOrEmpty(end) && end != "null")
            {
                DateTime dt2 = Convert.ToDateTime(end);
                query = from obj in query where obj.date <= dt2 orderby obj.id descending select obj;
            }
            if (!string.IsNullOrEmpty(opertor) && opertor != "null")
            {
                if (opertor != "所有操作员")
                {
                    query = from obj in query where obj.operatorId == opertor orderby obj.id descending select obj;
                }
            }
            if (!string.IsNullOrEmpty(memberCardId) && memberCardId != "null")
            {
                query = from obj in query where obj.memberCardId == memberCardId orderby obj.id descending select obj;
            }
            return query;
        }
    }
}
